<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // jsonp跨域
        function jsonp(obj) {
            obj.type = obj.type || 'get';
            obj.url = obj.url || '';
            let data = { ...obj.data };
            var arr = [];
            for (var k in data) {
                arr.push(`${k}=${data[k]}`)
            }
            obj.url = `${obj.url}?${arr.join('&')}`;
            var script = document.createElement('script');
            script.src = obj.url;
            document.body.appendChild(script)
            window[data.cb] = function (data) {
                return obj.success(data)
            }
        }
        jsonp({
            url: 'http://localhost:3000/say',
            data: {
                wd: 'zs',
                cb: 'show'
            },
            success: function (data) {
                console.log(data)
            }
        })
    </script>
</body>

</html>